package com.ruoyi.web.controller.qiankuantongji;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qiankuantongji.domain.Qiankuantongji;
import com.ruoyi.qiankuantongji.service.IQiankuantongjiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 欠款统计Controller
 *
 * @author ruoyi
 * @date 2023-05-25
 */
@Api(tags="欠款统计")
@RestController
@RequestMapping("/system/qiankuantongji")
public class QiankuantongjiController extends BaseController
{
    @Autowired
    private IQiankuantongjiService qiankuantongjiService;

    /**
     * 查询欠款统计列表
     */
    @ApiOperation("查询欠款统计列表")
    @PreAuthorize("@ss.hasPermi('xsgl:qktj:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qiankuantongji qiankuantongji)
    {
        startPage();
        List<Qiankuantongji> list = qiankuantongjiService.selectQiankuantongjiList(qiankuantongji);
        return getDataTable(list);
    }

    /**
     * 导出欠款统计列表
     */
    @ApiOperation("导出欠款统计列表")
//    @PreAuthorize("@ss.hasPermi('system:qiankuantongji:export')")
    @Log(title = "欠款统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Qiankuantongji qiankuantongji)
    {
        List<Qiankuantongji> list = qiankuantongjiService.selectQiankuantongjiList(qiankuantongji);
        ExcelUtil<Qiankuantongji> util = new ExcelUtil<Qiankuantongji>(Qiankuantongji.class);
        util.exportExcel(response, list, "欠款统计数据");
    }

    /**
     * 获取欠款统计详细信息
     */
    @ApiOperation("获取欠款统计详细信息")
//    @PreAuthorize("@ss.hasPermi('system:qiankuantongji:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(qiankuantongjiService.selectQiankuantongjiById(id));
    }

    /**
     * 新增欠款统计
     */
    @ApiOperation("新增欠款统计")
//    @PreAuthorize("@ss.hasPermi('system:qiankuantongji:add')")
    @Log(title = "欠款统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qiankuantongji qiankuantongji)
    {
        return toAjax(qiankuantongjiService.insertQiankuantongji(qiankuantongji));
    }

    /**
     * 修改欠款统计
     */
    @ApiOperation("修改欠款统计")
//    @PreAuthorize("@ss.hasPermi('system:qiankuantongji:edit')")
    @Log(title = "欠款统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qiankuantongji qiankuantongji)
    {
        return toAjax(qiankuantongjiService.updateQiankuantongji(qiankuantongji));
    }

    /**
     * 删除欠款统计
     */
    @ApiOperation("删除欠款统计")
//    @PreAuthorize("@ss.hasPermi('system:qiankuantongji:remove')")
    @Log(title = "欠款统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qiankuantongjiService.deleteQiankuantongjiByIds(ids));
    }
}
